<?php

namespace Modules\Common\Models;

use Modules\Common\Models\Validation\SiteMessageValidation;


class SiteMessage extends BaseModel
{
    protected $connection = 'mysql';
    protected $table = 'site_messages';
    use SiteMessageValidation;


    public static function system2EmployeeUser($userId, $content, $title = '系统消息', $is_broadcast = 0)
    {
        self::createFromArray([
            'from_id' => 0,
            'from_type' => 0,
            'to_id' => $userId,
            'to_type' => 2,
            'title' => $title,
            'content' => $content,
            'has_read' => 0,
            'is_broadcast' => $is_broadcast
        ]);
    }


    public static function system2EnterpriseUser($userId, $content, $title = '系统消息', $is_broadcast = 0)
    {
        self::createFromArray([
            'from_id' => 0,
            'from_type' => 0,
            'to_id' => $userId,
            'to_type' => 1,
            'title' => $title,
            'content' => $content,
            'has_read' => 0,
            'is_broadcast' => $is_broadcast
        ]);

    }

}
